﻿using System;

namespace MessageHandler
{
	public partial class UserInfo : IComparable
	{
		public override bool Equals(object obj)
		{
			if (obj is UserInfo)
			{
				UserInfo tmp = (UserInfo)obj;
				try
				{
					if (this.ipField != null && !this.ipField.Equals(tmp.ipField))
					{
						return false;
					}
					if (this.passwordField != null && !this.passwordField.Equals(tmp.passwordField))
					{
						return false;
					}
					if (!this.portField.Equals(tmp.portField))
					{
						return false;
					}
					if (this.usernameField != null && !this.usernameField.Equals(tmp.usernameField))
					{
						return false;
					}
					return true;
				}
				catch (Exception)
				{
					return false;
				}

			}
			return false;
		}

		public override string ToString()
		{
			return this.usernameField;
		}

		#region IComparable Member

		public int CompareTo(object obj)
		{
			UserInfo info = (UserInfo)obj;
			return this.usernameField.CompareTo(info.usernameField);
		}

		#endregion
	}
}
